package com.fishsb19.asuscomm.hashtable;

public class MyHashTable {
	private String[] hashTable;
	private int hashTableSize;
	/**
	 * Constructor
	 * Initialize all parameters
	 * occupied each space use special #### as Tombstone
	 * @param dataLength
	 */
public MyHashTable(int dataLength){
	this.hashTableSize=dataLength;
	hashTable=new String[this.hashTableSize];
	for(int tempCount=0;tempCount<this.hashTableSize;tempCount++){
		this.hashTable[tempCount]=new String("####");
	}
}
/**
 * getSize Method
 * Called by the MyHashTableInterface
 * @return
 */
	public int getSize() {
		return this.hashTableSize;
	}
/**
 * getData Method
 * Called by the MyHashTableInterface(searching,inserting,deleting)
 * @param index
 * @return
 */
	public String getData(int index) {
		return this.hashTable[index];
	}
/**
 * deleteData Method
 * Called by the MyHashTableInterface(deleting)
 * Remark the Tombstone #### when need to clear current space
 * @param index
 */
	public void deleteData(int index) {
		this.hashTable[index] = new String("####");
	}
/**
 * insertData Method
 * Called by the MyHashTableInterface(inserting)
 * Save the string in the target space with specific index
 * @param index
 * @param data
 */
	public void insertData(int index, String data) {
		this.hashTable[index] =new String(data);
	}
/**
 * isOccupied Method
 * Called by the MyHashTableInterface(inserting)
 * Check the availability of the HashTable space with specific index 
 * @param index
 * @return
 */
	public boolean isOccupied(int index) {
		if (!this.hashTable[index].equals("####"))
			return true;
		return false;
	}

}
